﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UIServices.Accounts;

namespace UIServices
{
    public class FacadeServices
    {
        internal CustomerAccountControl LoginManagerService { get; set; }
        public AccountManager AccountManagerService { get; set; }

        private FacadeServices()
        {
            AccountManagerService = AccountManagerBuilder.CreateAccountManager();
        }

        private static volatile FacadeServices instance = null;
        private static object syncRoot = new object();
        public static FacadeServices Instance
        {
            get
            {
                // only create a new instance if one doesn't already exist.
                if (instance == null)
                {
                    // use this lock to ensure that only one thread is access
                    // this block of code at once.
                    lock (syncRoot)
                    {
                        if (instance == null)
                            instance = new FacadeServices();
                    }
                }
                // return instance where it was just created or already existed.
                return instance;
            }
        }
    }
}
